Skip to content

Make verification repeatable for minKey (PrimMST.java) - #75

Open
hotasourav8-sketch wants to merge 1 commit into
S-AI-Projects:masterfrom
hotasourav8-sketch:student/e26b07f0855/R45-T025
Open

hotasourav8-sketch wants to merge 1 commit into
S-AI-Projects:masterfrom
hotasourav8-sketch:student/e26b07f0855/R45-T025

Conversation

@hotasourav8-sketch

Copy link
Copy Markdown

Description
This PR introduces repeatable, isolated unit and parameterized tests for PrimMST.minKey(). Previously, minKey() was only exercised indirectly via primMST(). This PR verifies its determinism, position independence, termination conditions, tie-breaking behavior, and input non-mutation.

Related Issue
Fixes: #25

Type of Change
● Tests

Changes Made

  • Added PrimMSTRepeatableTest.java.
  • Added repeated test to guarantee deterministic behavior.
  • Added parameterized tests across all indices [0..4] for position independence.
  • Verified edge cases: all vertices in MST (returns -1) and all unvisited keys equal to Integer.MAX_VALUE (returns -1).
  • Verified tie-breaking stability and input array non-mutation.
  • Simulated multi-step vertex selection matching full MST generation.

Screenshots / Recordings
N/A (Backend / Unit test changes only)

Testing
Executed JUnit 5 test suite:
mvn test -Dtest=PrimMSTRepeatableTest

Checklist
● I have tested my changes locally.
● I have added or updated tests, if needed.
● I have updated documentation, if needed.
● I have followed the project's coding guidelines.
● I have run the relevant tests and checks.
● I have addressed previous review feedback, if applicable.

Additional Notes
Directly addresses the lack of unit-level verification for the minKey helper method.

Add repeatable and parameterized tests for PrimMST.minKey:
- Verify determinism and idempotency via repeated test runs
- Parameterize minKey across all valid vertex indices [0..4]
- Verify boundary behavior when all vertices are included in MST (-1)
- Verify boundary behavior when all unvisited vertices have Integer.MAX_VALUE (-1)
- Verify strict tie-breaking behavior towards lowest index
- Verify input non-mutation guarantees
- Verify multi-step MST construction simulation

Fixes: S-AI-Projects#25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sourav Hota — R45-T025: Make verification repeatable for minKey (PrimMST.java) [src/main/java/com/thealgorithms/datastructures/graphs/PrimMST.java]

1 participant